package com.example.serialportdemo;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements SerialPortTool.OnSerialPortDataReceiveListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        //串口号ttyS1
        SerialPortToolManager.getInstance().openSerialPort("ttyS1", MainActivity.this);
    }

    @Override
    public void onDataReceive(String serialNum, String hexStr, long currentTimeMillions) {
        LogUtil.e("\n时间-->" + currentTimeMillions + "\n串口serialNum-->"+ serialNum + "\n接收到的数据-->"+ hexStr );
    }

    @Override
    public void onPortOffLineOutTime(String time, String portNum) {
        LogUtil.e("串口离线");
    }
}
